﻿using Ldt.DataEngine.RuleAssemble;
using LdtDataEngin.ModuleDetail.PersonnelAnalysis.PersonnelModel.Interface;
using LdtDataEngin.ModuleDetail.PersonnelAnalysis.PersonnelModel.Model;
using LdtJudge.DataEngine.Common.CommHelp;
using LdtJudge.DataEngine.Common.DateAssemble;
using LdtJudge.DataEngine.Common.MoneyAssemble;
using LdtJudge.DataEngine.Common.StringAssemble;
using LdtJudge.DataEngine.Common.XmlUtility;
using LdtJudge.DataEngine.DataBaseStores;
using LdtJudge.DataEngine.Model.DataModel.DataParseStorage;
using LdtJudge.DataEngine.Model.Personnel;
using LdtJudge.DataEngine.Model.XMLConfigModel.PersonnelConfigModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace LdtDataEngin.ModuleDetail.PersonnelAnalysis.PersonnelModel.Personnel
{
    /// <summary>
    /// 人员基础信息加载
    /// </summary>
    public class PersonnelBaseClass
    {
        #region 基础信息

        /// <summary>
        /// 代称集合
        /// </summary>
        Dictionary<string, string> dicspname = new Dictionary<string, string>();
        /// <summary>
        ///角色及其对应的发言人
        /// </summary>
        protected Dictionary<string, List<ElementSpokeName>> DictRoleSpokemen { get; set; }
        /// <summary>
        /// 角色技数器
        /// </summary>
        private IDictionary<string, int> _roleCounter = new Dictionary<string, int>();

        public string xmlconfig;

        public DataContext dataContext;
        #endregion

        public PersonnelBaseClass(DataContext dataLayer)
        {
            this.dataContext = dataLayer;

            dicspname.Add("ForfreeFirst", "RIU1910211527420001");
            dicspname.Add("ForfreeSpokesman", "RIU1910211528370001");
            dicspname.Add("DefendantIndex", "RIU1910241832210001");
            dicspname.Add("regSuitDegreeMatchWords", @"Judger=审,长,审判长,审判员,问,\?,？;Accused=被,被1,被2,被3,被4,被5,一被,二被,三被,四被,五被,被保;Defender=辨,一辨,二辨,三辨,四辨,五辨,辨1,辨2,辨3,辨4,辨5,辩,一辩,二辩,三辩,四辩,五辩,辩1,辩2,辩3,辩4,辩5,辩护人,辨护人;Prosecutor=公,公诉人,原,原告;ProseProxy=原代;AccusedProxy=被代;LegalAgent=法定代理人,法定代理;");
            LoadePersonnel();
            DictRoleSpokemen = GetShortNameList();
            // PersonnelInformation();


        }
        public void Loade()
        {
            PersonneInfo(xmlconfig);
        }

        #region 加载初始化内容
        /// <summary>
        /// 获取人员代称信息
        /// </summary>
        /// <param name="originalText">原文</param>
        /// <returns></returns>
        public IList<string> GetAllSpokeShortName(string originalText)
        {
            IList<string> allSpokeShortName = new List<string>();
            string regSpokeContentReg = RuleParseClass.GerParseReg(dicspname["ForfreeFirst"])[0];
            string extractText = RuleParseClass.GerParseReg(dicspname["ForfreeFirst"])[0];
            string regSpokeMenShortNameReg = RuleParseClass.GerParseReg(dicspname["ForfreeSpokesman"])[0];
            MatchCollection matchArr = Regex.Matches(originalText, regSpokeMenShortNameReg);
            foreach (Match omatch in matchArr)
            {
                string oReg2 = RuleParseClass.GerParseReg("RIU1910211532430001")[0];
                if (Regex.IsMatch(omatch.Value, oReg2) || !Regex.IsMatch("证实", omatch.Value))
                {
                    if (!allSpokeShortName.Contains(omatch.Value))
                        allSpokeShortName.Add(omatch.Value);
                }
                string oReg = RuleParseClass.GerParseReg("RIU1910211532430001")[0];
                if (Regex.IsMatch(omatch.Value, oReg) || !Regex.IsMatch("证实", omatch.Value))
                {
                    if (!allSpokeShortName.Contains(omatch.Value))
                        allSpokeShortName.Add(omatch.Value);
                }
            }
            return allSpokeShortName;
        }

        /// <summary>
        /// 获取角色与代称的对应关系
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, List<ElementSpokeName>> GetShortNameList()
        {
            Dictionary<string, List<ElementSpokeName>> roleSpokemen = new Dictionary<string, List<ElementSpokeName>>();
            string courtRecordText = dataContext.DataLayerAns.FengXiCanShu.Juanzongneirong;//原文
            string regSuitDegreeMatchWords = dicspname["regSuitDegreeMatchWords"];//正则内容
            IList<string> allSpoke = GetAllSpokeShortName(courtRecordText); //获取获取代称
            foreach (string spoker in allSpoke)
            {
                string indexMatchReg = RuleParseClass.GerParseReg("RIU1910241630150001")[0];
                Match indexMatch = Regex.Match(spoker, indexMatchReg);
                string roleIndex = (indexMatch != null) ? indexMatch.Value : "";
                double roleIndexNumb = (roleIndex == "") ? 1 : LdtMoneyFormat.DecodeNumberCn(roleIndex);//根据正则获取角色
                string pattern = RuleParseClass.GerParseReg("RIU1910241700460001")[0].Replace("(@{Name})", spoker);
                Match RoleMatch = Regex.Match(regSuitDegreeMatchWords, pattern);
                string roleName = string.Empty;
                if (RoleMatch != null && RoleMatch.Value != string.Empty)
                {
                    roleName = RoleMatch.Value;
                }
                else
                {
                    string iReg = RuleParseClass.GerParseReg(dicspname["DefendantIndex"])[0]; //得到被告的序号
                    if (Regex.IsMatch(spoker, RuleParseClass.GerParseReg("RIU1910241632170001")[0]))//上诉代理人
                    {
                        if (dataContext.DataLayerAns.CaseType == "b1" || dataContext.DataLayerAns.CaseType == "a1")
                        {
                            roleName = "ProseProxy";
                        }
                        else
                        {
                            roleName = "AppellantAgent";
                        }
                    }

                    if (Regex.IsMatch(spoker, RuleParseClass.GerParseReg("RIU1910241633470001")[0]))//被上诉代理人
                    {
                        if (dataContext.DataLayerAns.CaseType == "b1" || dataContext.DataLayerAns.CaseType == "a1")
                        {
                            roleName = "AccusedProxy";
                        }
                        else
                        {
                            roleName = "AppelleeAgent";
                        }
                    }

                    if (Regex.IsMatch(spoker, RuleParseClass.GerParseReg("RIU1910241634580001")[0]))
                        roleName = "Defender";
                    if (Regex.IsMatch(spoker, iReg))//修改防止匹配到三被告 二被告这种
                    {
                        if (spoker.IndexOf("被告") <= 0)
                        {
                            roleName = "Accused";
                        }
                    }
                }
                if (roleName == string.Empty) roleName = "undefined";
                //法庭笔录发文人
                ElementSpokeName mspokeman = new ElementSpokeName();
                mspokeman.ES_FullName = string.Empty;
                mspokeman.ES_ShortName = spoker;
                mspokeman.ES_Role = roleName;
                mspokeman.ES_RoleIndex = roleIndexNumb.ToString();
                mspokeman.ES_SuitDrgreeID = string.Empty;
                mspokeman.ES_SuitDegreeName = string.Empty;
                if (!roleSpokemen.ContainsKey(roleName))
                {
                    List<ElementSpokeName> currRoleList = new List<ElementSpokeName>();
                    roleSpokemen.Add(roleName, currRoleList);
                }
                roleSpokemen[roleName].Add(mspokeman);

            }
            return roleSpokemen;
        }
        #endregion


        /// <summary>
        /// 人员代称对比
        /// </summary>
        public void PersonnelInformation()
        {
            string MatchParameterStr = "Prosecutor=2,89,164;Accused=1,90;";//诉讼参与人
            string MatchAgentParameterStr = "Defender=168,169,13,99,100,101,102,103;Proxy=170,171,172,173,178,180;";//代理人
            string MatchAgentParameterJudger = "Judger=t1,t2,t9";
            string ParamenterType = "1";//1诉讼参与人 2代理人
            foreach (ElementSpokeName elementspoke in dataContext.DataLayerAns.ElementSpokeList)
            {
                string rowRoleName = "";
                IStart start = new PartyInformation() { dataContext=dataContext};
                if (MatchParameterStr.IndexOf(elementspoke.ES_SuitDrgreeID) > -1)
                {
                    ParamenterType = "1";
                    rowRoleName = DictionariesConver.GetArgumentValueByMatchWords(MatchParameterStr, elementspoke.ES_SuitDrgreeID);

                }
                else if (MatchAgentParameterStr.IndexOf(elementspoke.ES_SuitDrgreeID) > -1)
                {
                    ParamenterType = "2";
                    string MatchParameterStrAgent = "ProseProxy=2,89,164;AccusedProxy=1,90;";
                    rowRoleName = DictionariesConver.GetArgumentValueByMatchWords(MatchAgentParameterStr, elementspoke.ES_SuitDrgreeID);
                    if (!string.IsNullOrEmpty(elementspoke.ES_AssertorID))
                    {
                        string agentSuitDrgreeID = dataContext.DataLayerAns.ElementSpokeList.FirstOrDefault(a => a.ES_ID == elementspoke.ES_AssertorID).ES_SuitDrgreeID;
                        if (rowRoleName == "Proxy")
                        {
                            //区分是原代还是被代
                            rowRoleName = DictionariesConver.GetArgumentValueByMatchWords(MatchParameterStrAgent, agentSuitDrgreeID);
                        }
                    }


                }
                else if (MatchAgentParameterJudger.IndexOf(elementspoke.ES_SuitDrgreeID) > -1)
                {
                    ParamenterType = "3";
                    rowRoleName = DictionariesConver.GetArgumentValueByMatchWords(MatchAgentParameterJudger, elementspoke.ES_SuitDrgreeID);
                }

                string name = UnifieHandle(elementspoke.ES_ID, elementspoke.ES_FullName, elementspoke.ES_ShortName, elementspoke.ES_SuitDrgreeID, rowRoleName, elementspoke.ES_Sex, start, ParamenterType, elementspoke.ES_SuitDegreeName);
                dataContext.DataLayerAns.Anjianshitijueses.FirstOrDefault(a => a.Anjianshitiid == elementspoke.ES_ID).Fayanrenmingcheng = name;
                dataContext.DataLayerAns.Anjianshitis.FirstOrDefault(a => a.Anjianshitiid == elementspoke.ES_ID).Anjianshitijueses.FirstOrDefault(a => a.Anjianshitiid == elementspoke.ES_ID).Fayanrenmingcheng = name;
            }
        }


        /// <summary>
        /// 根据配置匹配人员信息.
        /// </summary>
        public void PersonneInfo(string xmlconfig)
        {
            if (!string.IsNullOrEmpty(xmlconfig))
            {
                PersonelRootModel personelRootModel = XmlUtility.DeserializeToObject<PersonelRootModel>(xmlconfig);
                Dictionary<string, List<ElementSpokeName>> roleSpokemenDic = GetShortNameList();
                if (roleSpokemenDic.ContainsKey("Accused"))
                {
                    List<ElementSpokeName> list = roleSpokemenDic["Accused"];
                    ElementSpokeName elementA = list.FirstOrDefault(a => a.ES_ShortName == "被告");
                    ElementSpokeName elementB = list.FirstOrDefault(a => a.ES_ShortName == "被一");
                    if (elementA!=null && elementB!=null)
                    {
                        roleSpokemenDic["Accused"].Remove(elementA);
                    }

                }
                string MatchParameterStr = "Prosecutor=2,89,164,7,104;Accused=1,90,13,29;";//诉讼参与人
                string MatchAgentParameterStr = "Defender=168,169,13,99,100,101,102,103;Proxy=170,171,172,173,178,180;";//代理人
                string MatchAgentParameterJudger = "Judger=t1,t2,t9,t12";
                string ParamenterType = "1";//1诉讼参与人 2代理人
                foreach (ElementSpokeName elementspoke in dataContext.DataLayerAns.ElementSpokeList)
                {
                    string rowRoleName = DictionariesConver.GetArgumentValueByMatchWords(MatchParameterStr, elementspoke.ES_SuitDrgreeID);
                    if (personelRootModel.personnelResultModelList.FirstOrDefault(a => a.suitdegreeid == elementspoke.ES_SuitDrgreeID) != null)
                    {
                        List<PersonnelResultModel> personnelResultModelList = personelRootModel.personnelResultModelList.Where(a => a.suitdegreeid == elementspoke.ES_SuitDrgreeID).ToList();
                        
                        if (MatchAgentParameterStr.Replace("Defender=","").Split(',').ToList().Contains(elementspoke.ES_SuitDrgreeID))
                        {
                            IStart start = new PartyInformation() { dataContext = dataContext };
                            ParamenterType = "2";
                            string MatchParameterStrAgent = "ProseProxy=2,89,164,7;AccusedProxy=1,90,13;";
                            rowRoleName = DictionariesConver.GetArgumentValueByMatchWords(MatchAgentParameterStr, elementspoke.ES_SuitDrgreeID);
                            if (!string.IsNullOrEmpty(elementspoke.ES_AssertorID))
                            {
                                string agentSuitDrgreeID = dataContext.DataLayerAns.ElementSpokeList.FirstOrDefault(a => a.ES_ID == elementspoke.ES_AssertorID)?.ES_SuitDrgreeID;
                                if (rowRoleName == "Proxy")
                                {
                                    //区分是原代还是被代
                                    rowRoleName = DictionariesConver.GetArgumentValueByMatchWords(MatchParameterStrAgent, agentSuitDrgreeID);
                                }
                            }

                            
                        }
                        string name = PersonneSpokeName(elementspoke, roleSpokemenDic, personnelResultModelList, rowRoleName);
                        elementspoke.ES_ShortName = name;
                        dataContext.DataLayerAns.Anjianshitijueses.FirstOrDefault(a => a.Anjianshitiid == elementspoke.ES_ID).Fayanrenmingcheng = name;
                        if (dataContext.DataLayerAns.Anjianshitis.FirstOrDefault(a => a.Anjianshitiid == elementspoke.ES_ID)!=null)
                        {
                            dataContext.DataLayerAns.Anjianshitis.FirstOrDefault(a => a.Anjianshitiid == elementspoke.ES_ID).Anjianshitijueses.FirstOrDefault(a => a.Anjianshitiid == elementspoke.ES_ID).Fayanrenmingcheng = name;

                        }

                    }

                }
            }
        }

        /// <summary>
        /// 获取发言人代称
        /// </summary>
        /// <param name="elementSpokeName"></param>
        /// <param name="roleSpokemenDic"></param>
        /// <param name="personnelResultModel"></param>
        /// <returns></returns>
        public string PersonneSpokeName(ElementSpokeName elementSpokeName, Dictionary<string, List<ElementSpokeName>> roleSpokemenDic, List<PersonnelResultModel> personnelResultModelList, string rowRoleName)
        {
            string name = "";
            List<ElementSpokeName> elementSpokeList = new List<ElementSpokeName>();
            if (roleSpokemenDic.ContainsKey(rowRoleName))
            {
                elementSpokeList = roleSpokemenDic[rowRoleName];

            }
            else
            {
                if (roleSpokemenDic.ContainsKey("undefined"))
                {
                    elementSpokeList = roleSpokemenDic["undefined"];
                    rowRoleName = "undefined";
                }
                
            }
            for (int i = 0; i < elementSpokeList.Count; i++)
            {

                ElementSpokeName roleSpokename = roleSpokemenDic[rowRoleName][i];
                foreach (PersonnelResultModel personnelResultModel in personnelResultModelList)
                {
                    foreach (PersonnelReg personnelReg in personnelResultModel.personnelRegList)
                    {

                        List<string> listParse = RuleParseClass.GetParseRegCodeList(personnelReg.code, roleSpokename.ES_ShortName);
                        if (listParse.Count > 0)
                        {
                            foreach (PersonnelMatching personnelMatching in personnelReg.personnelMatchingList)
                            {
                                if (!string.IsNullOrWhiteSpace(personnelMatching.index))
                                {
                                    List<string> listIndex = RuleParseClass.GetParseRegCodeList(personnelMatching.index, roleSpokename.ES_ShortName);
                                    if (listIndex.Count > 0)
                                    {
                                        int startInt = Convert.ToInt32(LdFormat.DecodeNumberCn(listIndex[0]));
                                        if (elementSpokeName.ES_RoleIndex == startInt.ToString() && string.IsNullOrWhiteSpace(name))
                                        {
                                            name = roleSpokename.ES_ShortName;
                                            roleSpokemenDic[rowRoleName].Remove(roleSpokename);
                                        }
                                        if (string.IsNullOrWhiteSpace(name) && !string.IsNullOrWhiteSpace(elementSpokeName.ES_AssertorID))
                                        {

                                            var elementsop = dataContext.DataLayerAns.ElementSpokeList.FirstOrDefault(a => a.ES_ID == elementSpokeName.ES_AssertorID && a.ES_RoleIndex == startInt.ToString());
                                            if (elementsop != null)
                                            {
                                                name = roleSpokename.ES_ShortName;
                                                roleSpokemenDic[rowRoleName].Remove(roleSpokename);
                                            }
                                        }
                                    }
                                }
                                else if (!string.IsNullOrWhiteSpace(personnelMatching.surname))
                                {
                                    List<string> listName = RuleParseClass.GetParseRegCodeList(personnelMatching.surname, roleSpokename.ES_ShortName);

                                    if (listName.Count > 0)
                                    {
                                        if (elementSpokeName.ES_FullName.IndexOf(listName[0]) == 0 && string.IsNullOrWhiteSpace(name))
                                        {
                                            name = roleSpokename.ES_ShortName;
                                            roleSpokemenDic[rowRoleName].Remove(roleSpokename);
                                        }
                                    }
                                }
                                else if (!string.IsNullOrWhiteSpace(personnelMatching.jiancheng))
                                {
                                    List<string> listIndex = RuleParseClass.GetParseRegCodeList(personnelMatching.jiancheng, roleSpokename.ES_ShortName);
                                    if (listIndex.Count > 0)
                                    {
                                        if (elementSpokeName.ES_ShortName == listIndex[0] && string.IsNullOrWhiteSpace(name))
                                        {
                                            name = roleSpokename.ES_ShortName;
                                            roleSpokemenDic[rowRoleName].Remove(roleSpokename);
                                        }
                                    }
                                }
                                else if (!string.IsNullOrWhiteSpace(personnelMatching.name))
                                {
                                    List<string> listIndex = RuleParseClass.GetParseRegCodeList(personnelMatching.name, roleSpokename.ES_ShortName);
                                    if (listIndex.Count > 0)
                                    {
                                        if (elementSpokeName.ES_FullName == listIndex[0] && string.IsNullOrWhiteSpace(name))
                                        {
                                            name = roleSpokename.ES_ShortName;
                                            roleSpokemenDic[rowRoleName].Remove(roleSpokename);
                                        }
                                    }
                                }
                                else if (!string.IsNullOrWhiteSpace(personnelMatching.beigongdai))
                                {
                                    List<string> listIndex = RuleParseClass.GetParseRegCodeList(personnelMatching.beigongdai, roleSpokename.ES_ShortName);
                                    if (listIndex.Count > 0)
                                    {
                                        if (elementSpokeName.Sp_participanttypeid == "t1" || elementSpokeName.Sp_participanttypeid == "t2")
                                        {
                                            name = roleSpokename.ES_ShortName;
                                            roleSpokemenDic[rowRoleName].Remove(roleSpokename);
                                        }
                                    }
                                }
                                else if (!string.IsNullOrWhiteSpace(personnelMatching.beibaodai))
                                {
                                    List<string> listIndex = RuleParseClass.GetParseRegCodeList(personnelMatching.beibaodai, roleSpokename.ES_ShortName);
                                    if (listIndex.Count > 0)
                                    {

                                        if (dataContext.DataLayerAns.ElementSpokeList.FirstOrDefault(a => a.ES_ID == elementSpokeName.ES_AssertorID).ES_FullName.IndexOf("保险") > -1)
                                        {
                                            name = roleSpokename.ES_ShortName;
                                            roleSpokemenDic[rowRoleName].Remove(roleSpokename);
                                        }
                                    }
                                }
                                else if(!string.IsNullOrWhiteSpace(personnelMatching.beibao))
                                {
                                    List<string> listIndex = RuleParseClass.GetParseRegCodeList(personnelMatching.beibao, roleSpokename.ES_ShortName);
                                    if (listIndex.Count > 0)
                                    {

                                        if (dataContext.DataLayerAns.ElementSpokeList.FirstOrDefault(a => a.ES_SuitDrgreeID == elementSpokeName.ES_SuitDrgreeID && a.ES_FullName.Contains("保险"))!=null)
                                        {
                                            name = roleSpokename.ES_ShortName;
                                            roleSpokemenDic[rowRoleName].Remove(roleSpokename);
                                        }
                                    }
                                }
                            }
                            if (personnelReg.personnelMatchingList.Count == 0)
                            {

                                if (listParse[0] == personnelResultModel.name)
                                {
                                    name = roleSpokename.ES_ShortName;
                                    roleSpokemenDic[rowRoleName].Remove(roleSpokename);
                                }

                            }
                        }
                    }
                }

            }
            if (string.IsNullOrWhiteSpace(name))
            {
                if (roleSpokemenDic.ContainsKey("undefined"))
                {
                    if (roleSpokemenDic["undefined"].FirstOrDefault(a => a.ES_ShortName == elementSpokeName.ES_FullName) != null)
                    {
                        name = roleSpokemenDic["undefined"].FirstOrDefault(a => a.ES_ShortName == elementSpokeName.ES_FullName).ES_ShortName;
                        roleSpokemenDic["undefined"].Remove(roleSpokemenDic["undefined"].FirstOrDefault(a => a.ES_ShortName == elementSpokeName.ES_FullName));
                    }
                }
                

            }
            return name;
        }

        /// <summary>
        /// 统一数据数据处理方式
        /// </summary>
        /// <param name="PersonID">当前人员的主键ID</param>
        /// <param name="fullName">当前人员全称</param>
        /// <param name="ShortName">当前人员简称</param>
        /// <param name="suitDegreeValue">当前人员诉讼地位</param>
        /// <param name="RowRoleName">当前人员角色</param>
        /// <param name="sex">当事人性别</param>
        /// <param name="sp_participanttypeid">当事人类型</param>
        private string UnifieHandle(string PersonID, string fullName, string ShortName, string suitDegreeValue, string RowRoleName, string sex, IStart startsuitpart, string ParamenterType, string suitDegreeName, string sp_participanttypeid = "")
        {
            string spokeshortname = "";
            if (!this.DictRoleSpokemen.ContainsKey(RowRoleName) && !string.IsNullOrEmpty(RowRoleName))
            {
                this.DictRoleSpokemen.Add(RowRoleName, new List<ElementSpokeName>() { });
            }
            int roleIndex = 1;
            if (this._roleCounter.ContainsKey(RowRoleName))
            {
                roleIndex = this._roleCounter[RowRoleName] + 1;
                this._roleCounter[RowRoleName] = roleIndex;
            }
            else
            {
                roleIndex = 1;
                this._roleCounter.Add(RowRoleName, roleIndex);
            }

            //笔录发文人;
            ElementSpokeName mspokeman = new ElementSpokeName()
            {
                ES_FullName = fullName,
                ES_ID = PersonID,
                ES_opid = PersonID.IndexOf("op") > -1 ? PersonID : "",
                ES_Sex = sex,
                ES_ProxyName = "",
                ES_Role = RowRoleName,
                ES_RoleIndex = roleIndex.ToString(),
                ES_ShortName = ShortName,
                ES_SuitDegreeName = suitDegreeName,
                ES_SuitDrgreeID = suitDegreeValue,
                ES_suitdrgreeidop = "",
                FL_ID = "",
                Sp_id = "",
                Sp_participanttypeid = sp_participanttypeid
            };
            mspokeman.ES_AssertorID = dataContext.DataLayerAns.ElementSpokeList.FirstOrDefault(a => a.ES_ID == PersonID).ES_AssertorID;
            ///进行人员数据的发言人信息处理
            TableModel tableModel = new TableModel();
            tableModel.spokeName = mspokeman;
            tableModel.spokeNameList = DictRoleSpokemen;
            switch (dataContext.DataLayerAns.CaseType)
            {
                case "a1":
                    tableModel.suitdegreList = new List<string>() { "1" };
                    tableModel.determine = new Determine.A1Determine();
                    if (ParamenterType == "1")
                    {
                        spokeshortname = startsuitpart.A1PersonnelStart(RowRoleName, tableModel);
                    }
                    else if (ParamenterType == "2")
                    {
                        spokeshortname = startsuitpart.A1AgentPersonnelStart(RowRoleName, tableModel);
                    }
                    else if (ParamenterType == "3")
                    {
                        spokeshortname = startsuitpart.TrialPersonnelStart(RowRoleName, tableModel);
                    }
                    break;
                case "a2":
                    //startsuitpart.A2Start();
                    break;
                case "b1":
                    tableModel.suitdegreList = new List<string>() { "89", "90" };
                    tableModel.determine = new Determine.B1Determine();
                    if (ParamenterType == "1")
                    {
                        spokeshortname = startsuitpart.B1PersonnelStart(RowRoleName, tableModel);
                    }
                    else if (ParamenterType == "2")
                    {
                        spokeshortname = startsuitpart.B1AgentPersonnelStart(RowRoleName, tableModel);
                    }
                    else if (ParamenterType == "3")
                    {
                        spokeshortname = startsuitpart.TrialPersonnelStart(RowRoleName, tableModel);
                    }
                    break;
                case "b2":
                    tableModel.suitdegreList = new List<string>() { "95", "100" };
                    tableModel.determine = new Determine.B2Determine();
                    if (ParamenterType == "1")
                    {
                        spokeshortname = startsuitpart.B2PersonnelStart(RowRoleName, tableModel);
                    }
                    else if (ParamenterType == "2")
                    {
                        spokeshortname = startsuitpart.B2AgentPersonnelStart(RowRoleName, tableModel);
                    }
                    else if (ParamenterType == "3")
                    {
                        spokeshortname = startsuitpart.TrialPersonnelStart(RowRoleName, tableModel);
                    }
                    break;
            }
            return spokeshortname;
        }
        /// <summary>
        /// 加载内容
        /// </summary>
        public void LoadePersonnel()
        {
            dataContext.DataLayerAns.ElementSpokeList = new List<ElementSpokeName>();
            if (dataContext.DataLayerAns.Anjianshitijueses!=null && dataContext.DataLayerAns.Anjianshitijueses.Any())
            {
                foreach (An_anjianshiti CaseEntity in dataContext.DataLayerAns.Anjianshitis)
                {
                    ElementSpokeName elementSpokeName = new ElementSpokeName();
                    elementSpokeName.ES_FullName = CaseEntity.Mingcheng;
                    elementSpokeName.ES_SuitDrgreeID = CaseEntity.Anjianshitijueses[0].Juesesusongdiwei;
                    elementSpokeName.ES_SuitDegreeName = CaseEntity.Anjianshitijueses[0].SusongDiwei;
                    elementSpokeName.ES_RoleIndex = CaseEntity.Anjianshitijueses[0].Juesexuhao.ToString() ;
                    elementSpokeName.ES_ID = CaseEntity.Anjianshitijueses[0].Anjianshitiid;
                    elementSpokeName.Sp_id = CaseEntity.Anjianshitijueses[0].Zhuzhangfangjihe;
                    elementSpokeName.ES_AssertorID = CaseEntity.Anjianshitijueses[0].Zhuzhangfangjihe;
                    elementSpokeName.ES_Sex = CaseEntity.Xingbie;
                    elementSpokeName.Sp_participanttypeid = CaseEntity.Anjianshitijueses[0].Dangshirenleixing;
                    dataContext.DataLayerAns.ElementSpokeList.Add(elementSpokeName);
                }
            }
        }

    }
}
